package com.baor.util;


import com.alibaba.fastjson.JSONObject;


public class R extends JSONObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public R(RCode rCode, Object data) {
		super.put("code", rCode.getCode());
		super.put("msg", rCode.getMsg());
		super.put("dataset", data);
	}
	public R(RCode rCode) {
		super.put("code", rCode.getCode());
		super.put("msg", rCode.getMsg());
	}
	public R(RCode rCode,String msg) {
		super.put("code", rCode.getCode());
		super.put("msg", msg);
	}
	public R(String msg) {
		super.put("code", "500");
		super.put("msg", msg);
	}

	public R() {
	}

	public static R ok() {
		return new R(RCode.SUCCESS);
	}
	public static R ok(Object data) {
		return new R(RCode.SUCCESS,data);
	}
	
	public static R er() {return new R(RCode.ERROR);}
	public static R er(String msg) {return new R(msg);}

	public static R unauth() {
		return new R(RCode.UNAUTHREZITED);
	}
	public static R unauth(String msg) {return new R(RCode.UNAUTHREZITED,msg);}
	public static R checkEr() {
		return new R(RCode.CHECKERROR);
	}
}
